package com.sky.controller.admin;

import com.sky.dto.SetmealDTO;
import com.sky.dto.SetmealPageQueryDTO;
import com.sky.result.Result;
import com.sky.service.SetmealService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController("adminSetmealController")
@RequestMapping("/admin/setmeal")
@Api(tags = "套餐相关接口")
public class SetmealController {
    @Autowired
    private SetmealService setmealService;

    /**
     * 新增套餐
     * @param setmealDTO
     * @return
     */
    @PostMapping
    public Result add(@RequestBody SetmealDTO setmealDTO){
        return setmealService.add(setmealDTO);
    }

    /**
     * 分页查询
     * @param dto
     * @return
     */
    @ApiOperation(value = "分页查询")
    @GetMapping("/page")
    public Result page(SetmealPageQueryDTO dto){
        return setmealService.page(dto);
    }

    /**
     * 修改启用状态
     * @param status
     * @param id
     * @return
     */
    @ApiOperation(value = "启用状态")
    @PostMapping("/status/{status}")
    public Result updateStatus(@PathVariable Integer status,Long id){
        return setmealService.updateStatus(status,id);
    }

    /**
     * 根据id查询
     * @param id
     * @return
     */
    @ApiOperation(value = "根据id查询")
    @GetMapping("/{id}")
    public Result getById(@PathVariable Long id){
        return setmealService.getById(id);
    }

    /**
     * 修改
     * @param setmealDTO
     * @return
     */
    @ApiOperation(value = "修改套餐")
    @PutMapping
    public Result update(@RequestBody SetmealDTO setmealDTO){
        return setmealService.update(setmealDTO);
    }

    /**
     * 删除套餐
     * @param ids
     * @return
     */
    @ApiOperation(value = "删除套餐")
    @DeleteMapping
    public Result delete(@RequestParam List<Long> ids){
        return setmealService.delete(ids);
    }
}
